package com.xy.tianyu.module.picture.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xy.tianyu.R
import com.xy.tianyu.module.picture.bean.PicTodayHotMultipleItem
import com.xy.tianyu.utils.GlideUtils
import kotlinx.android.synthetic.main.item_pic_today_hot_hor.view.*
import kotlinx.android.synthetic.main.item_pic_today_hot_square.view.*
import kotlinx.android.synthetic.main.item_pic_today_hot_ver.view.*

/**
 * @time 2020/9/30 11:32
 * @class 描述:
 */
class PicTodayHotAdapter(data:MutableList<PicTodayHotMultipleItem>):BaseMultiItemQuickAdapter<PicTodayHotMultipleItem,BaseViewHolder>(data) {
    init {
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_HOR,R.layout.item_pic_today_hot_hor)
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_VER,R.layout.item_pic_today_hot_ver)
        addItemType(PicTodayHotMultipleItem.PIC_HOT_TODAY_SQUARE,R.layout.item_pic_today_hot_square)
    }
    override fun convert(holder: BaseViewHolder, item: PicTodayHotMultipleItem) {
        val picAttrs1 = item.picTodayHotItem1.pic_attrs
        val picAttrs2 = item.picTodayHotItem2.pic_attrs

        when(item.itemType){
           PicTodayHotMultipleItem.PIC_HOT_TODAY_HOR -> {
               Glide.with(context).load(picAttrs1.thumb_url).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_hor)
           }
           PicTodayHotMultipleItem.PIC_HOT_TODAY_VER -> {
               Glide.with(context).load(picAttrs1.thumb_url).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_ver_one)
               Glide.with(context).load(picAttrs2.thumb_url).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_ver_two)
           }
           PicTodayHotMultipleItem.PIC_HOT_TODAY_SQUARE -> {
               Glide.with(context).load(picAttrs1.thumb_url).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_square_one)
               Glide.with(context).load(picAttrs2.thumb_url).apply(GlideUtils.getRoundRequestOptions()).into(holder.itemView.iv_pic_today_hot_square_two)
           }
       }
    }
}